package com.wind.trademark.base.controller;


import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wind.trademark.base.model.BsCategory;
import com.wind.trademark.base.service.CategoryService;
import com.wind.trademark.common.vo.ComboBean;
import com.wind.trademark.common.vo.PageBean;
import com.wind.trademark.common.vo.PageParam;

@Controller
public class CategoryController {
	@Autowired
	private CategoryService categoryService;

	private static final Log log = LogFactory.getLog(CategoryController.class);

	

	@RequestMapping
	public @ResponseBody
	PageBean queryCategory(PageParam pageParam,
			@RequestParam Map<String, Object> params) {

		PageBean pageBean = categoryService.queryCategory(pageParam, params);
		return pageBean;
	}

//	@RequestMapping
//	public @ResponseBody
//	List<ComboBean>  goolgeL2Category(@RequestParam("queryParam")String queryParam) {
//		return categoryService.goolgeL2Category(queryParam);
//	}
	@RequestMapping
	public @ResponseBody
	List<BsCategory>  getL1AndL2Category() {
		return categoryService.getL1AndL2Category();
	}
	@RequestMapping
	public @ResponseBody
	List<ComboBean>  getL2Category() {
		return categoryService.getL2Category();
	}
	
	@RequestMapping
	public @ResponseBody
	List<ComboBean>  goolgeL1AndL2Category(@RequestParam Map<String, Object> params) {
		return categoryService.goolgeL1AndL2Category(params);
	}
	
//	@RequestMapping
//	public @ResponseBody
//	BsCategory saveCategory(BsCategory category) {
//		return categoryService.saveCategory(category);
//	}
//	@RequestMapping
//	public @ResponseBody
//	BsCategory updateCategory(BsCategory category) {
//		 categoryService.updateCategory(category);
//		return category;
//	}
//	@RequestMapping
//	public @ResponseBody
//	BsCategory updateCategoryEnName(BsCategory category) {
//		 categoryService.updateCategoryEnName(category);
//		return category;
//	}
	
	@RequestMapping
	public @ResponseBody
	Long[] deleteCategories(Long[] ids) {
		 categoryService.deleteCategories(Arrays.asList(ids));
		 return ids;
	}
	
	@RequestMapping
	public @ResponseBody
	BsCategory saveOrUpdateCategory(BsCategory category) {
		return categoryService.saveOrUpdateCategory(category);
	}
	
	@RequestMapping
	public @ResponseBody
	BsCategory loadCategory(Long id) {
		return categoryService.loadCategory(id);
	}
	
	
}
